
<!DOCTYPE html>

<html>
  
<!-- Mirrored from docs.sympy.org/latest/modules/holonomic/uses.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:28:21 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=utf-8" /><!-- /Added by HTTrack -->
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

    <title>Uses and Current limitations &#8212; SymPy 1.9 documentation</title>
    <link rel="stylesheet" type="text/css" href="../../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../../_static/default.css" />
    <link rel="stylesheet" type="text/css" href="../../_static/graphviz.css" />
    <link rel="stylesheet" type="text/css" href="../../_static/plot_directive.css" />
    <link rel="stylesheet" type="text/css" href="../../../../live.sympy.org/static/live-core.css" />
    <link rel="stylesheet" type="text/css" href="../../../../live.sympy.org/static/live-autocomplete.css" />
    <link rel="stylesheet" type="text/css" href="../../../../live.sympy.org/static/live-sphinx.css" />
    
    <script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
    <script src="../../_static/jquery.js"></script>
    <script src="../../_static/underscore.js"></script>
    <script src="../../_static/doctools.js"></script>
    <script src="../../../../live.sympy.org/static/utilities.js"></script>
    <script src="../../../../live.sympy.org/static/external/classy.js"></script>
    <script src="../../../../live.sympy.org/static/live-core.js"></script>
    <script src="../../../../live.sympy.org/static/live-autocomplete.js"></script>
    <script src="../../../../live.sympy.org/static/live-sphinx.js"></script>
    <script async="async" src="../../../../cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest8331.js?config=TeX-AMS_HTML-full"></script>
    <script type="text/x-mathjax-config">MathJax.Hub.Config({"tex2jax": {"inlineMath": [["\\(", "\\)"]], "displayMath": [["\\[", "\\]"]]}})</script>
    
    <link rel="shortcut icon" href="../../_static/sympy-notailtext-favicon.ico"/>
    <link href="uses.html" rel="canonical" />
    
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <link rel="next" title="Internal API" href="internal.html" />
    <link rel="prev" title="Converting other representations to holonomic" href="convert.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="internal.html" title="Internal API"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="convert.html" title="Converting other representations to holonomic"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../index.html" >SymPy Modules Reference</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="index.html" accesskey="U">Holonomic</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">Uses and Current limitations</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="uses-and-current-limitations">
<h1>Uses and Current limitations<a class="headerlink" href="#uses-and-current-limitations" title="Permalink to this headline">¶</a></h1>
<section id="integration">
<h2>Integration<a class="headerlink" href="#integration" title="Permalink to this headline">¶</a></h2>
<p>One can perform integrations using holonomic functions by following these steps:</p>
<ol class="arabic simple">
<li><p>Convert the integrand to a holonomic function.</p></li>
<li><p>Now integrate the holonomic representation of the function.</p></li>
<li><p>Convert the integral back to expressions.</p></li>
</ol>
<section id="examples">
<h3>Examples<a class="headerlink" href="#examples" title="Permalink to this headline">¶</a></h3>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">a</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">sin</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.holonomic</span> <span class="kn">import</span> <span class="n">expr_to_holonomic</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">expr_to_holonomic</span><span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">+</span><span class="n">a</span><span class="p">),</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">integrate</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">to_expr</span><span class="p">()</span>
<span class="go">atan(x/sqrt(a))/sqrt(a)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">expr_to_holonomic</span><span class="p">(</span><span class="n">sin</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="o">/</span><span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">integrate</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">to_expr</span><span class="p">()</span>
<span class="go">Si(x)</span>
</pre></div>
</div>
<p>As you can see in the first example we converted the function to holonomic, integrated the result
and then converted back to symbolic expression.</p>
</section>
</section>
<section id="limitations">
<h2>Limitations<a class="headerlink" href="#limitations" title="Permalink to this headline">¶</a></h2>
<p>1. Converting to expressions is not always possible. The holonomic function
should have a hypergeometric series at <code class="docutils literal notranslate"><span class="pre">x0</span></code>.</p>
<p>2. Implementation of converting to holonomic sequence currently doesn’t support
<code class="docutils literal notranslate"><span class="pre">Frobenius</span> <span class="pre">method</span></code> when the solutions need to have <span class="math notranslate nohighlight">\(\log\)</span> terms. This happens
when at least one pair of the roots of the indicial equation differ by an integer and
frobenius method yields linearly dependent series solutions. Since we use this while converting
to expressions, sometimes <a class="reference internal" href="operations.html#sympy.holonomic.holonomic.HolonomicFunction.to_expr" title="sympy.holonomic.holonomic.HolonomicFunction.to_expr"><code class="xref py py-func docutils literal notranslate"><span class="pre">to_expr()</span></code></a> fails.</p>
<p>3. There doesn’t seem to be a way for computing indefinite integrals, so <a class="reference internal" href="operations.html#sympy.holonomic.holonomic.HolonomicFunction.integrate" title="sympy.holonomic.holonomic.HolonomicFunction.integrate"><code class="xref py py-func docutils literal notranslate"><span class="pre">integrate()</span></code></a>
basically computes <span class="math notranslate nohighlight">\(\int_{x_0}^{x} f(x)dx\)</span> if no limits are given, where <span class="math notranslate nohighlight">\(x_0\)</span> is the point at
which initial conditions for the integrand are stored. Sometimes this gives an additional constant in the result.
For instance:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">expr_to_holonomic</span><span class="p">(</span><span class="n">sin</span><span class="p">(</span><span class="n">x</span><span class="p">))</span><span class="o">.</span><span class="n">integrate</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">to_expr</span><span class="p">()</span>
<span class="go">1 - cos(x)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">sin</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">integrate</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="go">-cos(x)</span>
</pre></div>
</div>
<p>The indefinite integral of <span class="math notranslate nohighlight">\(\sin(x)\)</span> is <span class="math notranslate nohighlight">\(-\cos(x)\)</span>. But the output is <span class="math notranslate nohighlight">\(-\cos(x) + 1\)</span>
which is <span class="math notranslate nohighlight">\(\int_{0}^{x} sin(x)dx\)</span>. Although both are considered correct but <span class="math notranslate nohighlight">\(-\cos(x)\)</span>
is simpler.</p>
</section>
</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="../../index.html">
              <img class="logo" src="../../_static/sympylogo.png" alt="Logo"/>
            </a></p>
  <h3><a href="../../index.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Uses and Current limitations</a><ul>
<li><a class="reference internal" href="#integration">Integration</a><ul>
<li><a class="reference internal" href="#examples">Examples</a></li>
</ul>
</li>
<li><a class="reference internal" href="#limitations">Limitations</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="convert.html"
                        title="previous chapter">Converting other representations to holonomic</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="internal.html"
                        title="next chapter">Internal API</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../../_sources/modules/holonomic/uses.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="https://docs.sympy.org/latest/search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="internal.html" title="Internal API"
             >next</a> |</li>
        <li class="right" >
          <a href="convert.html" title="Converting other representations to holonomic"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../index.html" >SymPy Modules Reference</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="index.html" >Holonomic</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">Uses and Current limitations</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2021 SymPy Development Team.
      Last updated on Sep 30, 2021.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.1.2.
    </div>
  </body>

<!-- Mirrored from docs.sympy.org/latest/modules/holonomic/uses.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:28:21 GMT -->
</html>